<template>
	<view class="content">
		<view class="content_top">
			<view class="list">
				<view class="title">通讯录成员</view>
				<view class="sum">2</view>
			</view>
			<view class="list">
				<view class="title">浏览数</view>
				<view class="sum">182</view>
			</view>
			<view class="list">
				<view class="title">入群状态</view>
				<view class="sum">开放</view>
			</view>
		</view>
		<view class="content_user">
			<view class="name">Mr、赵创建的通讯录</view>
			<view class="time">2025-05-22</view>
		</view>
		<view class="content_title">
			基本设置
		</view>
		<view class="content_list">
			<view class="list" @click="link('/admin/user/user')">
				<view class="title">成员管理</view>
				<view class="sum">(2人)</view>
			</view>
			<view class="list" @click="link('/admin/set/set')">
				<view class="title">通讯录设置</view>
			</view>
			<view class="list">
				<view class="title">推广海报</view>
			</view>
		</view>
		<view class="content_title">
			高级设置
		</view>
		<view class="content_list">
			<view class="list" @click="addTxlShow = true">
				<view class="title">导入名单</view>
			</view>
			<view class="list">
				<view class="title">导出名单</view>
			</view>
			<view class="list" @click="link('/admin/set/setGl')">
				<view class="title">管理员设置</view>
			</view>
		</view>
		<view class="content_list">
			<view class="list" @click="link('/admin/user/userInfo')">
				<view class="title">我的信息</view>
			</view>
			<view class="list"></view>
			<view class="list"></view>
		</view>
		<view class="content_bottom">
			<view class="button">
				<view class="item">删除通讯录</view>
				<view class="item" @click="tgShow = true">推广通讯录</view>
			</view>
		</view>
		<!-- 推广弹框 -->
		<view class="tgBox" v-if="tgShow">
			<view class="bj" @click="tgShow = false"></view>
			<view class="box">
				<image mode="widthFix" src="https://txl.cnpowder.com.cn/getshareimg.php?txlid=27"></image>
			</view>
		</view>
		<view class="upBox" v-if="addTxlShow">
			<view class="bj" @click="addTxlShow = false"></view>
			<view class="box">
				<view class="listTop">
					<view class="list" @click="link('/admin/user/adduser')">单个录入成员</view>
					<view class="list" @click="upExcel">电脑Excel批量导入</view>
				</view>
				<view class="listBottom" @click="addTxlShow = false">取消</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		link
	} from '@/utils/utils.js'
	import {
		ref,
		defineProps,
	} from 'vue'
	const tgShow = ref(false)
	const addTxlShow = ref(false)
	
	const selectedFile = ref(null);
	const uploadResult = ref(null);
	const upExcel = () => {
		wx.chooseMessageFile({
		  count: 1, // 最多可选择的文件数量
		  type: 'file', // 可以是 'image'、'video'、'all' 或 'file'
		  extension: ['.xlsx', '.xls'], // 限制文件扩展名
		  success(res) {
		    // 返回选定文件的本地临时路径列表
		    const tempFilePaths = res.tempFilePaths;
		    const tempFiles = res.tempFiles;
		    
		    console.log('选择的文件路径:', tempFilePaths);
		    console.log('文件详情:', tempFiles);
		    
		    // 后续可以上传文件到服务器
		    uploadFile(tempFilePaths[0]);
		  },
		  fail(err) {
		    console.error('选择文件失败:', err);
		  }
		});
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100%;
		height: 100%;
		background: #f5f6fa;

		&_top {
			width: calc(100% - 60rpx);
			padding: 30rpx;
			background: linear-gradient(0deg, #f31801, #e94f06);
			display: flex;
			align-items: center;
			justify-content: center;

			.list {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				flex: 1;
				color: #fff;
				border-right: 1rpx solid #fff;

				.title {
					font-size: 34rpx;
				}

				.sum {
					font-size: 38rpx;
					font-weight: bold;
					margin-top: 20rpx;
				}
			}

			.list:nth-last-child(1) {
				border-right: none;
			}
		}

		&_user {
			margin-top: 30rpx;
			background: #fff;
			width: calc(100% - 60rpx);
			padding: 30rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-size: 30rpx;

			.time {
				color: #999;
			}
		}

		&_title {
			width: calc(100% - 60rpx);
			padding: 30rpx;
			font-size: 28rpx;
			color: #999;
		}

		&_list {
			width: 100%;
			display: flex;
			background: #fff;

			.list {
				flex: 1;
				border-right: 1px solid #f5f6fa;
				border-bottom: 1px solid #f5f6fa;
				display: flex;
				flex-direction: column;
				align-items: center;
				padding-top: 50rpx;
				padding-bottom: 50rpx;

				.title {
					font-size: 30rpx;
				}

				.sum {
					font-size: 28rpx;
					color: #999;
					margin-top: 10rpx;
				}
			}
		}

		&_bottom {
			width: 100%;
			height: 100rpx;

			.button {
				width: 100%;
				height: 100rpx;
				position: fixed;
				bottom: 0;
				left: 0;
				display: flex;
				background: #fff;
				box-shadow: 0 0 5rpx 0 rgba(0, 0, 0, .2);

				.item {
					flex: 1;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 36rpx;
					color: #e94f06;
				}

				.item:nth-child(2) {
					background: #e94f06;
					color: #fff;
				}
			}
		}
	}

	.tgBox {
		width: 100%;
		height: 100%;
		position: fixed;
		left: 0;
		top: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 999;

		.bj {
			width: 100%;
			height: 100%;
			position: absolute;
			background: #000;
		}

		.box {
			width: 100%;
			position: absolute;

			image {
				width: 100%;
			}
		}
	}
	.upBox{
		width: 100%;
		height: 100%;
		position: fixed;
		left: 0;
		top: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 999;
		
		.bj {
			width: 100%;
			height: 100%;
			position: absolute;
			background: rgba(0, 0, 0, .2);
		}
		.box{
			width: 100%;
			position: absolute;
			bottom: 0;
			left: 0;
			display: flex;
			flex-direction: column;
			align-items: center;
			padding-bottom: 30rpx;
			.listTop{
				width: calc(100% - 60rpx);
				.list{
					width: 100%;
					padding-top: 30rpx;
					padding-bottom: 30rpx;
					font-size: 32rpx;
					border-bottom: 1px solid #b0b0b0;
					background: #fefefe;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 32rpx;
					border-radius: 8px 8px 0 0;
				}
				.list:nth-last-child(1){
					background: #ededed;
					border-bottom: none;
					border-radius:0px 0px 8px 8px;
				}
			}
			.listBottom{
				width: calc(100% - 60rpx);
				padding-top: 30rpx;
				padding-bottom: 30rpx;
				background: #fefefe;
				border-radius: 8px;
				display: flex;
				align-items: center;
				justify-content: center;
				margin-top: 50rpx;
				color: #3478f6;
				font-size: 36rpx;
				font-weight: bold;
			}
		}
	}
</style>